home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / p_pascal.zip / SAMPLES / GCD.PAS < prev    next >
Pascal/Delphi Source File  |  1989-04-25  |  417b  |  21 lines

  1. (*$c+,d+*)
  2. PROGRAM example(input,output);
  3. VAR x, y : integer;
  4. FUNCTION gcd(a, b: integer) : integer;
  5. BEGIN
  6.  {GREATEST COMMON DENOMINATOR PROGRAM:}
  7.   CASE b = 0 OF
  8.    true: gcd := a;
  9.   false: gcd := gcd(b, a MOD b)
  10.   END
  11. END;
  12. BEGIN
  13.   write('type x = ');
  14.   readln(x);
  15.   writeln('x = ', x : 2);
  16.   write('type y = ');
  17.   readln(y);
  18.   writeln('y = ', y : 2);
  19.   writeln('gcd = ', gcd(x,y) : 2, '.')
  20. END.
  21.